package com.buba.record.service.impl;

import com.buba.pojo.record.Record;
import com.buba.record.VoL.RecordVoL;
import com.buba.pojo.user.PatientCard;
import com.buba.record.VoL.RecordjlVoL;
import com.buba.record.mapper.RecordMapper;
import com.buba.record.service.RecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.buba.record.vo.RecordVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import com.buba.utils.R;
import com.buba.record.vowl.ConsumptionVoWL;
import com.buba.record.vowl.RecordVoWL;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 记录表 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2022-06-09
 */
@Service
@Slf4j
public class RecordServiceImpl extends ServiceImpl<RecordMapper, Record> implements RecordService {

    @Autowired
    private RecordMapper recordMapper;


    @Override
    public List<RecordVoWL> findAllCon(ConsumptionVoWL cVO) {
        return recordMapper.findAllCon(cVO);
    }

    @Override
    public R getByRID(Integer id) {
        RecordVoWL r =  recordMapper.getByRID(id);
        RecordVoL recordVoL = this.selectByrIDtoyp(id);
        return R.ok().data("recordVoWL",r).data("recordVoL",recordVoL);
    }

    public RecordVoL selectByrIDtoyp(Integer id) {
        return baseMapper.selectByrIDtoyp(id);
    }

    @Override
    public List<RecordVo> patientSkype(Integer id) {
        return recordMapper.patientSkype(id);
    }

    @Override
    public List<RecordVo> recordDate(Integer id, String begin, String end) {
        return recordMapper.recordDate(id , begin , end);
    }

    @Override
    public RecordVo cardBalance(Integer id) {
        log.info("cardBalance:::"+id);
        RecordVo patientCard = recordMapper.cardBalance(id);
        log.info("patientCard:::"+patientCard);
        return patientCard;
    }

    @Override
    public RecordVo recordById(Integer id) {
        return recordMapper.recordById(id);
    }

    @Override
    public RecordVo drugRecordById(Integer id) {
        return recordMapper.drugRecordById(id);
    }
    @Override
    public R selectByInpatientID(Integer id) {
        RecordVoL recordVoL = baseMapper.selectByInpatientID(id);

        return R.ok().data("record", recordVoL);
    }
    @Override
    public R selectjlByInpatientID(Integer id) {
        List<RecordjlVoL> recordjlVoL = baseMapper.selectjlByInpatientID(id);

        return R.ok().data("recordjlVo", recordjlVoL);
    }

    @Override
    public R selectjlByInpatientdrugRecordSerialNumber(Integer drugRecordSerialNumber) {

            RecordjlVoL recordjlVoL = baseMapper.selectjlByInpatientdrugRecordSerialNumber(drugRecordSerialNumber);

        return R.ok().data("recordjlVo", recordjlVoL);
    }

    @Override
    public RecordVo recordByrId(Integer id) {
        return recordMapper.recordByrId(id);
    }

    @Override
    public R selectByInpatientrlsh(Integer id) {
        RecordVoL recordVoL = baseMapper.selectByInpatientrlsh(id);

        return R.ok().data("record", recordVoL);
    }

    @Override
    public List<RecordVo> patientRecordById(Integer id, String begin, String end) {
        return recordMapper.patientRecordById(id , begin , end);
    }
}
